ImageView同寬不同長


Posted by Limon on 2023-06-02

有一個新需求是recyclerView item要每個ImageView寬match_parent,長則依照每個照片不失真為前提,每個照片的長度不一樣。

recyclerView可以設定setHasFixedSize,設定為false recyclerView會依照每個item height wrap_content。

ImageView xml加上

android:adjustViewBounds="true"
android:scaleType="fitStart"

本來我一直在載入圖片的code調整,結果發現在ImageView加上自動調整的屬性就好了

Picasso.get().load(url).placeholder(defaultDrawable).into(imageView);









Related Posts

序列化操作(Gson ObjectMapper)

序列化操作(Gson ObjectMapper)

[Linux] wsl系統遷移

[Linux] wsl系統遷移

資結、Introduction to Algorithm Design

資結、Introduction to Algorithm Design


Comments